package lec10.am.cal;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Controller extends View implements ActionListener {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	Model model;

	public void setModel(Model model) {
		this.model = model;
	}

	public Controller() {
		model = new Model();
		eq.addActionListener(this);

	}

	@Override
	public void actionPerformed(ActionEvent e) {
		if (e.getSource() == eq) {
			model.setA(Integer.parseInt(ta.getText()));
			model.setB(Integer.parseInt(tb.getText()));
			model.compute();
			int result = model.getC();
			tc.setText(Integer.toString(result));

		}

	}

}
